package plus.chendd.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import plus.chendd.entity.TrainingMenu;
import plus.chendd.mapper.TrainingMenuMapper;
import plus.chendd.service.TrainingMenuService;

import java.util.List;

@Service
public class TrainingMenuServiceImpl implements TrainingMenuService {
  
  @Autowired
  private TrainingMenuMapper menuMapper;
  
  /**
   * 查询所有的数据
   */
  @Override
  public List<TrainingMenu> findAll() {
    return menuMapper.selectList(null);
  }
  
  @Override
  @Cacheable(value = "trainingMenu", key = "#id")
  public TrainingMenu findById(String id) {
    return menuMapper.selectById(id);
  }
  
  @CachePut(value = "trainingMenu", key = "#trainingMenu.id")
  @Override
  public int updateById(TrainingMenu trainingMenu) {
    return menuMapper.updateById(trainingMenu);
  }
}
